<template>
  <!--邀请记录-->
  <div class="jilu">
    <div class="search">
      <p>
        <span style="margin-right: 30px">账户余额:{{amount}}</span>
        <span style="margin-left: 30px">佣金总金额:{{totalCommission}}</span>
      </p>
    </div>

    <div class="page-infinite-wrapper" ref="wrapper" :style="{ height: wrapperHeight + 'px' }">
      <wv-group
        v-infinite-scroll="getList"
        infinite-scroll-disabled="loading"
        infinite-scroll-distance="10"
      >
        <wv-panel class="lists">
          <wv-media-box thumb="" v-for="(item,index) in list" :title="item.serverName" :key="index" type="text">
            <ul class="weui-media-box__info" slot="box_ft">
              <li>标题：{{item.title}}</li>
              <li>内容：{{item.body}}</li>
              <li v-if="item.type==1">金额：+{{item.amount}}</li>
              <li v-if="item.type==2">金额：-{{item.amount}}</li>
              <li>创建日期：{{item.createDate}}</li>
            </ul>
          </wv-media-box>
        </wv-panel>
      </wv-group>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import {agentWallet} from '../../utils/http'

  export default {
    name: 'mywallet',
    props: {},
    data() {
      return {
        page: 1,
        rows: 10,
        pages: 0,
        list: [],
        amount: 0,
        totalCommission: 0,
        wrapperHeight: 0,
        loading: false,
      };
    },
    methods: {
      getList() {
        this.loading = true;
        let params = {
          content: this.content,
          page: this.page,
          rows: this.rows
        };
        agentWallet(params).then(res => {
          console.log(res);
          if (res.code == 100) {
            let data = res.object;
            let amount = data.balance.amount;
            let totalCommission = data.totalCommission;
            this.amount = amount;
            this.totalCommission = totalCommission;
            let list = data.pqGrid.rows;
            let pages = data.pqGrid.pages;
            this.pages = pages;
            let totalNum = data.totalNum;
            this.totalNum = totalNum;
            if (list.length > 0) {
              this.list = this.list.concat(list);
            }
          }
          if (this.page < this.pages) {
            this.page++;
            this.loading = false
          } else {
            this.loading = true
          }
        }).catch(err => {
          console.log(err);
        });
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

  .weui-panel:before {
    border-top: none;
  }

  .lists {
    text-align: left;

    .weui-media-box__info span {
      position: absolute;
      right: 25px;
      top: 20px;
      font-size: 15px;
      color: #666;
    }

    .weui-media-box__info {
      li {
        color: #666;
        margin-bottom: 15px;
        font-size: 13px;
      }

      li:last-child {
        font-size: 12px;
        color: #999;
      }
    }
  }

  .search {
    position: relative;
    width: 95%;
    margin: 10px auto;
    display: flex;

    p {
      width: 96%;
      border: 1px solid #eee;
      box-shadow: 0 3px 4px rgba(17, 17, 17, 0.05);
      border-radius: 7px;
      height: 40px;
      line-height: 40px;
      padding: 10px;
      color: #3b9cf9;
    }

  }
</style>
